#include <stdio.h>

struct BinaryTreeNode
{
  int m_nValue;
  BinaryTreeNode* m_pLeft;
  BinaryTreeNode* m_pRight;
};

bool DoseTree1HaveTree2(BinaryTreeNode* pRoot1, BinaryTreeNode* pRoot2);
bool hasSubTree(BinaryTreeNode* pRoot1, BinaryTreeNode* pRoot2)
{
  bool result = false;

  if(pRoot1 != NULL && pRoot2 != NULL)
  {
    if(pRoot1->m_nValue == pRoot2->m_nValue)
    {
      result = DoseTree1HaveTree2(pRoot1, pRoot2);
    }
    if(!result)
    {
      result = hasSubTree(pRoot1->m_pLeft, pRoot2);
    }
    if(!result)
    {
      result = hasSubTree(pRoot1->m_pRight, pRoot2);
    }
  }
  
  return result;
}

bool DoseTree1HaveTree2(BinaryTreeNode* pRoot1, BinaryTreeNode* pRoot2)
{
  if(pRoot2 == NULL)
  {
    return true;
  }

  if(pRoot1 == NULL)
  {
    return false;
  }

  if(pRoot1->m_nValue != pRoot2->m_nValue)
  {
    return false;
  }

  return DoseTree1HaveTree2(pRoot1->m_pLeft, pRoot2->m_pLeft) && DoseTree1HaveTree2(pRoot1->m_pRight, pRoot2->m_pRight);
}

int main(int argc, char const *argv[])
{
  
  return 0;
}

